package com.eastfair.tag.controller;

import com.eastfair.core.base.R;
import com.eastfair.tag.dto.TagTargetDTO;
import com.eastfair.tag.service.TagTargetService;
import com.eastfair.tag.vo.TagTargetVO;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * <p>
 * 前端控制器
 *
 * </p>
 *
 * @author zjn
 * @date 2022-03-11
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/tagTarget")
public class TagTargetController {

    @Autowired
    private TagTargetService tagTargetService;

    /**
     * 主体标签直接绑定
     *
     * @param tagTargetDTO 主体标签信息
     * @return 是否成功
     */
    @ApiOperation("主体标签直接绑定")
    @PostMapping({"/saveTagTarget"})
    public R<Boolean> saveTagTarget(@RequestBody TagTargetDTO tagTargetDTO) {
        return tagTargetService.saveTagTarget(tagTargetDTO);
    }

    /**
     * 主体标签间接绑定
     *
     * @param tagTargetDTO 主体资源信息
     * @return 是否成功
     */
    @ApiOperation("主体标签间接绑定")
    @PostMapping({"/saveTagTargetByResourceType"})
    public R<Boolean> saveTagTargetByResourceType(@RequestBody TagTargetDTO tagTargetDTO) {
        return tagTargetService.saveTagTargetByResourceType(tagTargetDTO);
    }

    /**
     * 获取主体标签
     *
     * @param tagTargetDTO 主体资源信息
     * @return 是否成功
     */
    @ApiOperation("获取主体标签")
    @PostMapping({"/getTargetTagList"})
    public R<List<TagTargetVO>> getTargetTagList(@RequestBody TagTargetDTO tagTargetDTO) {
        return tagTargetService.getTargetTagList(tagTargetDTO);
    }

}
